import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
matplotlib.use('TkAgg')  # 或者 'Qt5Agg', 'Agg', 等


# 你的混淆矩阵
confusion_matrix =  [



    [446365, 229, 128, 72, 1596, 137, 11, 16, 1, 175, 3225, 66, 14, 39, 5],

    [644, 949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],

    [93, 0, 25139, 1, 125, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],

    [162, 0, 0, 1836, 3, 0, 2, 0, 0, 0, 0, 0, 0, 51, 0],

    [825, 0, 374, 2, 44425, 15, 0, 0, 0, 0, 0, 1, 0, 0, 0],

    [222, 0, 0, 0, 0, 814, 31, 0, 0, 0, 0, 0, 0, 0, 1],

    [340, 0, 0, 0, 0, 30, 758, 5, 0, 1, 32, 2, 0, 0, 1],

    [204, 0, 0, 0, 0, 0, 6, 1345, 0, 0, 0, 0, 0, 0, 0],

    [0, 0, 0, 0, 0, 0, 0, 0, 1110, 0, 0, 0, 0, 0, 0],

    [230, 0, 0, 48, 0, 0, 0, 0, 0, 1476, 0, 0, 0, 0, 0],

    [2080, 0, 0, 0, 22, 0, 0, 0, 0, 0, 29672, 1, 0, 0, 1],

    [24, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 1163, 0, 0, 0],

    [14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 61, 232, 0, 916],

    [99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 410, 0, 530, 0],

    [61, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 5, 56, 0, 924]

]

# 将混淆矩阵转换为NumPy数组
cm = np.array(confusion_matrix)

# 设置类别标签
class_names = ['Class 0', 'Class 1', 'Class 2', 'Class 3', 'Class 4',
               'Class 5', 'Class 6', 'Class 7', 'Class 8', 'Class 9',
               'Class 10', 'Class 11', 'Class 12', 'Class 13', 'Class 14']

# 绘制混淆矩阵
plt.figure(figsize=(10, 7))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues', xticklabels=class_names, yticklabels=class_names)
plt.xlabel('Predicted')
plt.ylabel('Truth')
plt.title('Confusion Matrix')
plt.show()